<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>商城会员</title>

    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />

    <link rel="stylesheet" href="../default/css/mui.min.css">
    <link rel="stylesheet" type="text/css" href="../default/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="../default/css/animat.min.css"/>
    <style>
        html {

        }

        body {
            background: #f2f3f5 url(https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/images/taskban.png) no-repeat;
            background-size: 100%;

        }

        .mui-bar {
            background: transparent;
        }

        .mui-bar-transparent {
            background: rgba(255, 219, 40, 0);
        }

        .mui-bar-tab {
            background: #fff;
        }

        .mui-fullscreen {
            top: 45px;
            bottom: 50px
        }

        .mui-content {
            background-color: transparent;
            margin-top: 44px;
            margin-bottom: 80px;
        }

        .mui-title {
            font-weight: 600;
        }

        .sign-box{
            margin: 10px 5px;
            border-radius: 0;
             -webkit-box-shadow: 0px 2px 11px white;
             box-shadow: 0px 2px 11px white;
        }
        #tosign {
            display: none;
        }

        .task-maseg1 {
            text-align: center;
            margin: 15px auto;
        }

        .userClass, .uservipcet {
            display: none;
        }
        .mui-slider-item{
            height: 200px;
            background-image: url('https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/images/tu2.png');
            background-repeat: no-repeat;
            background-size: 100% 162px;
            position: relative;
        }
        .times{
            font-size: 11px;
            color: #296269;
            position: absolute;
            top: 135px;
            left: 18px;
        }
    </style>

</head>
<body>

<header id="header" class="mui-bar mui-bar-transparent">
    <a class="back-tohost mui-icon mui-icon-left-nav mui-pull-left" onclick="javascript:history.back(-1);"></a>
    <h1 class="mui-title">商城会员</h1>
</header>

<div class="mui-content">
    <div class="mui-row">
        <div class="mui-col-sm-6 mui-col-xs-6" id="wallet">
            <a href="wallet.html" class="black">
                <div class="task-maseg">
                    <h3 id="commission">--</h3>
                    <p>佣金</p>
                </div>
            </a>
        </div>
        <!--<div class="mui-col-sm-4 mui-col-xs-4">-->
            <!--<a href="reading-treasure.html" class="black">-->
                <!--<div class="task-maseg">-->
                    <!--<h3 id="balance">&#45;&#45;</h3>-->
                    <!--<p>阅读宝</p>-->
                <!--</div>-->
            <!--</a>-->
        <!--</div>-->
        <div class="mui-col-sm-6 mui-col-xs-6">
            <a href="addfriends.html" class="black" id="addfriend">
                <div class="task-maseg">
                    <h3 id="userfriend">--</h3>
                    <p>好友</p>
                </div>
            </a>
        </div>
    </div>
    <!--<p class="mui-text-center red">会员等级: <b id="areMembers"></b></p>
    <p class="mui-text-center red" id="vipena">您的VIP会员将于 <b id="dueTime"></b>到期</p>-->
    <div class="mui-row">
        <div class="mui-col-sm-12 mui-col-xs-12 userClass">
            <div class="task-maseg1">
                <!--<h3 id="balance">&#45;&#45https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/icon/vip-1.png;</h3>-->
                <img src="" alt="" width="70" class="userClassimg">
                <p class="mui-text-center red">商城会员等级: <b id="areMembers"></b></p>
                <!--<div class="uservipcet">
                    <p class="mui-text-center red" id="vipena">您的VIP会员将于 <b id="dueTime"></b>到期</p>
                </div>-->
            </div>
        </div>
    </div>
    <div class="sign-box" id="treasure">
        <div style="height:100px;padding: auto 5px;background: #fed632;color: white;">
            <div style="padding:25px 0 0 10px;float: left;width:50%;text-align: center">
            <p style="color: white">阅读宝</p>
            <b id="balances" style="font-size: 40px;">--</b>
            </div>
            <div style="float: left;width: 14%;margin-left: 87px;margin-top: 25px;">
                <img src="https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/images/shop/Logo.png" width="100%" height="100%">
            </div>
        </div>
        <div style="height: 30px;background: #fdbc03;">
            <div style="text-align: center;width:50%">
            <span style="line-height: 30px;color: white;padding-left: 10px;font-size: 12px;">10阅读宝=1元</span>
            </div>
        </div>
    </div>

    <div class="sign-box">
         <div class="mui-slider-item">
                    <!--<img src="https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/images/tu.png"/></div>-->
                <!--支持循环，需要重复图片节点-->
             <span class="times">有效期至&nbsp;<span id="times"></span></span>
         </div>
    </div>

<!-- 底部导航 -->

<nav class="mui-bar mui-bar-tab">
    <a class="mui-tab-item" href="../../index.html">
        <span class="mui-icon icon iconfont icon-xinwen"></span>
        <span class="mui-tab-label">首页</span>
    </a>
    <a class="mui-tab-item" href="./video.html">
				<span class="mui-icon icon iconfont icon-shipin">
					<!-- <span class="mui-badge">9</span> --></span>
        <span class="mui-tab-label">视频</span>
    </a>
    <a class="mui-tab-item mui-active" href="./shops.html">
        <span class="mui-icon icon iconfont icon-shangcheng"></span>
        <span class="mui-tab-label">阅读宝商城</span>
    </a>
    <a class="mui-tab-item" href="./task.html">
        <span class="mui-icon icon iconfont icon-task"></span>
        <span class="mui-tab-label">任务</span>
    </a>
</nav>


<script src="../default/js/jquery-2.14.js" type="text/javascript" charset="utf-8"></script>
<script src="../default/js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../default/js/cookie.js"></script>
<script src="../default/js/code.js" type="text/javascript" charset="utf-8"></script>
<script src="../default/js/index.js" type="text/javascript" charset="utf-8"></script>
<script src="../default/js/public.js"></script>

<!--<script src="../default/js/vconsole.js" type="text/javascript" charset="utf-8"></script>-->
<!-- <script src="../default/js/mui.lazyload.js"></script> -->
<!-- <script src="../default/js/mui.lazyload.img.js"></script> -->
<script>
    /*mui.showLoading("正在加载..","div");
    setTimeout(function () {
        mui.hideLoading();
    },1000)*/
    mui.showLoading("正在加载..", "div");



    mui('body').on('tap', '#wallet', function (e) {
        mui.openWindow({
            url: 'wallets.html'
        });
    });
    mui('body').on('tap', '#addfriend', function (e) {
        mui.openWindow({
            url: 'addfriends.html'
        });
    });
    mui('body').on('tap', '.mui-slider-item', function (e) {
        mui.openWindow({
            url: 'news-shop.html'
        });
    });

    $(function () {
        findByUserBalance();
        querySubordinate();
        querySubordinate1();
        checkInToday();
        continuousSignIn();
        // queryFindBrowse();
        // findByUserId2();
        taskTypeController();
        // dueTimevip();
        /* }else{
             localStorage.clear();
             setTimeout(function () {
                 mui.openWindow({
                         url: "http://newst.whilte.com/index.html",
                     });
             }, 500)
         }*/

    });
    // var userId= 9;
    // 用户签到状态
    var singstate = '';
    // 用户签到天数
    var singstateindex = '';
    // ajax地址


    var quantityOfTime = 0;

    var msg;

    mui.init({
        swipeBack: true //启用右滑关闭功能
    });

    mui('.mui-bar-tab').on('tap', 'a', function (e) {
        e.preventDefault();
        if($(this).is('.no')){
            mui.toast('暂未开放');
        }else{
            mui.openWindow({
                url: $(this).attr('href')
            });
        }
    });

    // document.getElementById("tosign").addEventListener("tap", function () {
    //     $("#tosign").hide(500);
    //
    //     if (singstate != '1') {
    //         mui.alert('提示', '您今天已经签到过,请明天再来~~');
    //         return false;
    //     } else {
    //         mui.showLoading("正在加载..", "div");
    //         var culation = parseInt(singstateindex) % 10;
    //         var earnBalance = '';
    //         if (culation == 9) {
    //             earnBalance = 1;
    //         } else {
    //             earnBalance = 1;
    //         }
    //         //用户签到
    //         $.ajax({
    //             url: website + '/SignInController/userCheckIn',
    //             type: 'post',
    //             data: {
    //                 userId: userId,
    //                 earnBalance: earnBalance
    //             },
    //             success: function (data) {
    //                 mui.alert('恭喜您签到成功', '签到成功', function () {
    //                     //更新用户余额
    //                     findByUserBalance();
    //                     //更新用户签到
    //                     continuousSignIn();
    //
    //                     mui.hideLoading();
    //
    //                 });
    //             }, error: function () {
    //                 mui.showLoading("发生错误,返回首页..", "div");
    //                 mui.openWindow({
    //                     url: "http://newst.whilte.com/index.html",
    //                 });
    //             }
    //         });
    //
    //     }
    // });


    /*mui('.exclusive-task-box').on('tap', '.mui-btn-warning', function(e) {
        e.preventDefault();
        mui.openWindow({
            url:'sendfriend.html'
        });
    });*/
    mui('.exclusive-task-box').on('tap', '.sendfriend', function (e) {
        e.preventDefault();
        mui.openWindow({
            url: 'sendfriend.html'
        });
    });
    mui('.exclusive-task-box').on('tap', '.data-cache', function (e) {
        localStorage.clear();
    });

    mui('.exclusive-task-box').on('tap', '.invitation', function (e) {
        e.preventDefault();
        mui.openWindow({
            url: 'invitation.html'
        });
    });




    mui('.exclusive-task-box').on('tap', '.myorderlist', function (e) {
        e.preventDefault();
        mui.openWindow({
            url: 'myOrder-list.html'
        });
    });

    mui('.exclusive-task-box').on('tap', '.phone', function (e) {
        e.preventDefault();
        mui.openWindow({
            url: 'account.html'
        });
    });
    mui('.exclusive-task-box').on('tap', '.zhuanzhang', function (e) {
        e.preventDefault();
        mui.openWindow({
            url: 'recharge.html'
        });
    });



    mui('.exclusive-task-box').on('tap', '.task-record', function (e) {
        e.preventDefault();
        mui.openWindow({
            url: 'task-record.html'
        });
        // mui.toast('暂未开放');
    });

    mui('.exclusive-task-box').on('tap', '.sendteam', function (e) {
        e.preventDefault();
        mui.openWindow({
            url: 'team.html'
        });
    });

    /*mui('.exclusive-task-box').on('tap', '.uploadScreenshots', function (e) {
        mui.showLoading("领取中..","div");
        if (quantityOfTime >= 15) {
            if (msg == '未转发') {
                $.ajax({
                    url: website + '/ForwardController/makeMoney1',
                    type: 'POST',
                    data: {
                        "userId": userId
                    },
                    success: function (data) {
                        mui.hideLoading();
                        console.log(data);
                        mui.toast("领取成功");
                        setTimeout(function () {

                            mui.openWindow({
                                url: 'task.html'
                            });
                        }, 500)
                    }
                });
            } else {
                mui.hideLoading();
                mui.toast("今日已领取");
            }

        } else {
            mui.hideLoading();
            mui.toast("今日阅读任务未完成");
        }
    });*/



    mui('.exclusive-task-box').on('tap', '.uploadScreenshots', function (e) {
        var urlId = $(this).attr('data-url-id');
        if(urlId==3 || urlId==4){
            $.ajax({
                url: website + '/ForwardController/findByUserId5',
                type: 'POST',
                data: {
                    "userId": userId,
                    "id":urlId
                },
                success: function (data) {

                    if(data.msg == '有'){
                        mui.toast('这个任务已经做过了!');
                        return false;
                    }else {
                        mui.openWindow({
                            url: "uploadScreenshots.html?taskid="+urlId
                        });
                    }
                }
            });
        }else{
            $.ajax({
                url: website + '/ForwardController/findByUserId4',
                type: 'POST',
                data: {
                    "userId": userId,
                    "taskTypeId":urlId
                },
                success: function (data) {

                    if(data.msg != '未做'){
                        mui.toast('这个任务已经做过了，请明天再来吧!');
                        return false;
                    }else {
                        mui.openWindow({
                            url: "uploadScreenshots.html?taskid="+urlId
                        });
                    }
                }
            });
        }


    });

    //获得slider插件对象
    var gallery = mui('.mui-slider');
    gallery.slider({
        interval: 3000 //自动轮播周期，若为0则不自动播放，默认为0；
    });

    /*
        function queryFindBrowse() {
            $.ajax({
                url: website + '/BrowseController/queryFindBrowse',
                type: 'POST',
                data: {
                    userId: userId
                },
                success: function (data) {
                    quantityOfTime = data.data.quantityOfTime;
                }
        }*/

    /*function findByUserId2() {
        $.ajax({
            url: website + '/ForwardController/findByUserId2',
            type: 'POST',
            data: {
                userId: userId
            },
            success: function (data) {
                msg = data.msg;
            }
        });
    }*/

    // 查询用户的分销佣金和阅读宝,和朋友
    function findByUserBalance() {
        // 查询用户的阅读宝和余额
        $.ajax({
            url: website + '/UserController/findByUserBalance ',
            type: 'post',
            data: {userId: userId},
            success: function (data) {
                if (data.data.balance == null) {
                    $("#balance").html('0');
                } else {
                    $("#balance").html(data.data.balance);
                    $("#balances").html(data.data.balance);
                }
                if (data.data.commission == null) {
                    $("#commission").html('0');
                } else {
                    $("#commission").html(data.data.commission);
                }

            }, error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxed752d87990909bb&redirect_uri=http://newst.whilte.com/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
            }
        });
    };

    function querySubordinate() {
        // 查出用户的所有下级用户
        $.ajax({
            url: website + '/OrderController/numberOfProducts',
            type: 'post',
            data: {userId: userId},
            success: function (data) {
                $("#userfriend").html(data.data);
            }, error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxed752d87990909bb&redirect_uri=http://newst.whilte.com/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
            }
        });
    };


    function querySubordinate1() {
        // 查出用户的所有下一级用户
        $.ajax({
            url: website + '/OrderController/viewUserMallLevel',
            type: 'post',
            data: {userId: userId},
            success: function (data) {
                $("#areMembers").html(data.data.mallGrade);
                var mystr=data.data.dueTimeTwo;
                if(data.data.mallGrade=="普通会员") {
                    $(".times").hide();
                }else{
                    $("#times").html(mystr.substring(0,11));
                }
                    $(".userClass").show();
                    $(".userClassimg").attr('src', 'https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/icon/vip-3.png')
            }, error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxed752d87990909bb&redirect_uri=http://newst.whilte.com/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
            }
        });
    };


    function checkInToday() {
        // 查询用户今日是否签到
        $.ajax({
            url: website + '/SignInController/checkInToday',
            type: 'post',
            data: {userId: userId},
            success: function (data) {
                if (data.msg == '已签到') {
                    $("#tosign").hide();
                    singstate = '0';
                } else {
                    $("#tosign").css('display', 'inline');
                    singstate = '1';
                }
            }, error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxed752d87990909bb&redirect_uri=http://newst.whilte.com/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
            }
        });
    };

    var userIsVip;
    /*function dueTimevip() {
        //判断用户vip到期时间
        userIsVip1();
        $.ajax({
            url: website + '/UserController/dueTime',
            type: 'post',
            data: {userId: userId},
            success: function (data) {
                if(userIsVip=='是'){
                    var num = data.data.substring(0, 10);
                    $("#dueTime").html(num);
                    $('.uservipcet').show();
                }
            }, error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                mui.openWindow({
                    url: "http://newst.whilte.com/index.html",
                });
            }
        });
    }*/


    function userIsVip1() {
        $.ajax({
            url: website + '/UserController/areMembers',
            type: 'post',
            data: {userId: userId},
            success: function (data) {
                userIsVip=data.data;
            }, error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxed752d87990909bb&redirect_uri=http://newst.whilte.com/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
            }
        });
    }

    // function UserController() {
    //     // 查询用户是否是代理
    //     $.ajax({
    //         url: website + '/UserController/findById',
    //         type: 'post',
    //         data: {id: userId},
    //         success: function (data) {
    //
    //             if(data.data=='否'){
    //                 uservip();
    //             }else{
    //                 $("#areMembers").html(data.data);
    //                 $(".userClass").show();
    //                 // dueTimevip();
    //             }
    //             console.log(data);
    //             // $("#dueTime").html(data.data.substring(0,10));
    //         }, error: function () {
    //             /*mui.showLoading("发生错误,返回首页..", "div");
    //             mui.openWindow({
    //                 url: "http://newst.whilte.com/index.html",
    //             });*/
    //         }
    //     });
    // }


    // function uservip() {
    //     //判断用户是否是vip
    //     $.ajax({
    //         url: website + '/UserController/areMembers',
    //         type: 'post',
    //         data: {userId: userId},
    //         success: function (data) {
    //
    //
    //             if (data.data == '是') {
    //
    //                 $("#areMembers").html('推广员');
    //                 $(".userClass").show();
    //                 // dueTimevip();
    //                 $(".userClassimg").attr('src', 'https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/icon/vip-2.png')
    //             } else {
    //                 $("#areMembers").html('读者会员');
    //                 $(".userClass").show();
    //                 $(".userClass").addClass('mui-col-sm-12 mui-col-xs-12');
    //                 $(".userClass").removeClass('mui-col-sm-6 mui-col-xs-6');
    //                 $(".userClassimg").attr('src', 'https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/icon/vip-1.png')
    //             }
    //             // $("#dueTime").html(data.data.substring(0,10));
    //         }, error: function () {
    //             mui.showLoading("发生错误,返回首页..", "div");
    //             window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxed752d87990909bb&redirect_uri=http://newst.whilte.com/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
    //         }
    //     });
    // }


    function continuousSignIn() {
        // 判断用户是否连续签到
        $.ajax({
            url: website + '/SignInController/continuousSignIn',
            type: 'post',
            data: {userId: userId},
            success: function (data) {
                $("#singdate").html(data.data);
                $('.cumulative>div:lt(10)').removeClass('cumulative-en');
                singstateindex = data.data;
                if (singstateindex == 0) {
                    $('.cumulative>div:lt(0)').addClass('cumulative-en');
                    return;
                } else if (singstateindex % 10 == 0) {
                    $('.cumulative>div:lt(10)').addClass('cumulative-en');
                    $('.cumulative>div:lt(9)').html('1');
                    $('#last-jiedian').html('1');
                    return;
                } else {
                    $('.cumulative>div:lt(' + singstateindex % 10 + ')').addClass('cumulative-en');
                    $('.cumulative>div:lt(' + singstateindex % 10 + ')').html('1');
                }

            }, error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxed752d87990909bb&redirect_uri=http://newst.whilte.com/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
            }
        });
    }

    function taskTypeController() {
        $.ajax({
            url: website + '/TaskTypeController/queryAll',
            type: 'post',
            success: function (data) {
                var html='';
                data.data.forEach(function (value) {
                    html+='<li class="mui-table-view-cell uploadScreenshots" data-url-id="'+value.id+'">\n' +
                        '                    <div class="mui-table">\n' +
                        '                    <div class="mui-col-xs-2 mui-col-sm-2 mui-inline">\n' +
                        '                    <img src="https://srhub.oss-cn-hangzhou.aliyuncs.com/zq-news/images/icon/follow.png" alt=""\n' +
                        '                width="50">\n' +
                        '                    </div>\n' +
                        '                    <div class="mui-col-xs-7 mui-col-sm-7 mui-inline">\n' +
                        '                    <h4 class="mui-ellipsis">'+value.taskName+'</h4>\n' +
                        '                    <span class="mui-h5">阅读宝+'+value.taskAmount+'</span>\n' +
                        '                    </div>\n' +
                        '                    <div class="mui-col-xs-3 mui-col-sm-3 mui-inline">\n' +
                        '                    <button type="button" class="mui-btn mui-btn-warning">打开任务</button>\n' +
                        '                    </div>\n' +
                        '                    </div>\n' +
                        '                    </li>'
                });

                $("#task-list").prepend(html);

            }, error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxed752d87990909bb&redirect_uri=http://newst.whilte.com/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
            }
        });
    }



    window.onload = function () {
        mui.hideLoading();
    }

</script>
</body>
</html>
